{template 'common/header'}
{php load()->func('tpl')}
<ul class="nav nav-tabs">
    <li {if $operation == 'display'} class="active" {/if}><a href="{php echo $this->createWebUrl('slide',array('op' =>'display'))}">幻灯片</a></li>
    <li{if $operation == 'post'} class="active" {/if}><a href="{php echo $this->createWebUrl('slide',array('op' =>'post'))}">添加幻灯片</a></li>
</ul>
{if $operation == 'display'}
<div class="main">
	<div class="panel panel-default">
		<div class="panel-body table-responsive">
            <table class="table table-hover">
                <thead class="navbar-inner">
                <tr>
                    <th style="width:60px;">ID</th>
                    <th style="width:80px;">排序</th>
                    <th>标题</th>
                    <th>连接</th>
                    <th style="width:10%;">分类</th>
                    <th style="width:150px">操作</th>
                </tr>
            </thead>
            <tbody>
                {loop $list $slide}
                <tr>
                    <td>{$slide['id']}</td>
                    <td>{$slide['displayorder']}</td>
                    <td>{$slide['title']}</td>
                    <td>{$slide['link']}</td>
                    <td>{$slide['cate']['title']}</td>
                    <td style="text-align:left;">
						<a href="{php echo $this->createWebUrl('slide', array('op' => 'post', 'id' => $slide['id']))}" class="btn btn-default">修改</a>
						<a href="{php echo $this->createWebUrl('slide', array('op' => 'delete', 'id' => $slide['id']))}" class="btn btn-default">删除</a>
					</td>
                </tr>
                {/loop}
            </tbody>
        </table>
        {$pager}
    </div>
</div>
</div>
{elseif $operation == 'post'}
<div class="main">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
    	<div class="panel panel-default">
            <div class="panel-heading">
        <input type="hidden" name="id" value="{$slide['id']}" />
                幻灯片 <span class="text-muted">幻灯片设置</span>
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
                    <div class="col-xs-12 col-sm-9">
                         <input type="text" class="form-control" placeholder="" name="displayorder" value="{$slide['displayorder']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">幻灯片标题</label>
                    <div class="col-xs-12 col-sm-9">
                         <input type="text" class="form-control" placeholder="" name="title" id="title" value="{$slide['title']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">幻灯片图片</label>
                    <div class="col-xs-12 col-sm-9">
						{php echo tpl_form_field_image('thumb',$slide['thumb']);}
	      				<span class="help-block">用幻灯片来更好的表现你的预约主题</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">幻灯片链接</label>
                    <div class="col-xs-12 col-sm-9">
                         <input type="text" class="form-control" placeholder="" name="link" id="link" value="{$slide['link']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否显示</label>
                    <div class="col-xs-12 col-sm-9">
                		<label class="radio-inline"><input type="radio" name="enabled" value="1" id="enabled1" {if empty($slide) || $slide['enabled'] == 1}checked="true"{/if} /> 显示</label>
		 				<label class="radio-inline"><input type="radio" name="enabled" value="0" id="enabled2" {if !empty($slide) && $slide['enabled'] == 0}checked="true"{/if} /> 隐藏</label>
                    <div class="help-block">是否在手机端显示该图片</div>
                    </div>
                </div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">请选择首页分类：</label>
					<div class="col-sm-9">
						<select class="form-control" name="cate">
								<option value="0" {if $slide['cid']=='0'} selected="selected"{/if}>仅首页显示</option>
							{loop $category $row}
								<option value="{$row['id']}" {if $row['id'] == $slide['cid']} selected="selected"{/if}>{$row['title']}</option>
							{/loop}
						</select>
					</div>
				</div>
				
     </div>
     </div>
        <div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>
<script language='javascript'>
    function formcheck() {
        if ($("#title").isEmpty()) {
            Tip.focus("title", "请填写幻灯片名称!", "right");
            return false;
        }
       
        return true;
    }
    
</script>
{/if}
{template 'common/footer'}